

#ifndef _PYHIGHLIGHTER_H__
#define _PYHIGHLIGHTER_H__

#include <QString>
#include <QFont>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QRegularExpression>
#include <QTextDocument>


#include "PyInterpreterAPI.hpp"

NAMESPACE_BEGIN(NSPyHighlighter)


class COMPILERAPI PyHighlighter : public QSyntaxHighlighter {
    
public:
    PyHighlighter(QTextDocument* parent = nullptr);
    ~PyHighlighter();

protected:
    void highlightBlock(const QString& text) override;

private:
    struct HighlightingRule {
        QRegularExpression pattern;
        QTextCharFormat format;
    };

    QVector<HighlightingRule> highlightingRules;
    QRegularExpression commentStartExpression;
    QRegularExpression commentEndExpression;
    QTextCharFormat keywordFormat;
    QTextCharFormat singleLineCommentFormat;
    QTextCharFormat multiLineCommentFormat;
    QTextCharFormat quotationFormat;
    QTextCharFormat functionFormat;
};



NAMESPACE_END

#endif // !_PYHIGHLIGHTER_H__


